// Filename: views/etudiant/list
define([
  'jQuery',
  'Underscore',
  'Backbone',
  // Pull in the Collection module from above
  'collections/etudiant',
  'text!templates/etudiant/list.html'

], function($, _, Backbone, etudiantCollection, etudiantListTemplate){
  var etudiantListView = Backbone.View.extend({
    el: $("#page"),
    initialize: function(){
      this.collection = etudiantCollection;
      this.collection.bind("add", this.exampleBind);
      /*this.collection = etudiantCollection.add({ name: "Twitter"});
      this.collection = etudiantCollection.add({ name: "Facebook"});
      this.collection = etudiantCollection.add({ name: "Myspace", score: 20});*/
    },
    exampleBind: function( model ){
      //console.log(model);
    },
    render: function(){
      var data = {
        etudiants: this.collection.models,
        _: _ 
      };
      var compiledTemplate = _.template( etudiantListTemplate, data );
      $("#page").html( compiledTemplate ); 
	  return this;
    }
  });
  return new etudiantListView;
});
